<template>
  <div>
    <h1>加加减减</h1>
    <ul>
      <li v-for="(item,index) in list" :key="index">
        <span>{{item}}</span>
        <button @click="delFn(index)">删除</button>
      </li>
    </ul>
    <button @click="addFn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list:[]
    }
  },
  methods: {
    addFn() {
      // 随机生成一个0-10的整数不包括10
      this.list.push(Math.floor(Math.random() * 10))
    },
    delFn(index) {
      this.list.splice(index,1)
    }
  }
}
</script>

<style>

</style>